home *** CD-ROM | disk | FTP | other *** search
/ ftp.uv.es / 2014.11.ftp.uv.es.tar / ftp.uv.es / pub / mac / graficos / hpgl-to-pict-hc.hqx / hp2pict deck / card_6097.txt < prev    next >
Text File  |  1982-12-17  |  18KB  |  675 lines

  1. -- card: 6097 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2253
  5. -- name: hp2pict.inc.c
  6.  
  7.  
  8. -- part contents for background part 1
  9. ----- text -----
  10. hp2pict.inc.c
  11.  
  12. -- part contents for background part 6
  13. ----- text -----
  14. /* hp2pict.inc.c
  15.  *
  16.  *
  17.  * Copyright 1990 by d.g.gilbert.
  18.  * dogStar Software && Indiana University Biology Dept.
  19.  * email: don.gilbert@iubio.bio.indiana.edu
  20.  *
  21.  */
  22.  
  23.  
  24.  
  25. /* hp2pict routines & data */
  26.  
  27. /* A4: 10800 x, 7680 y -- GCG driver: 10170-44x, 7840-384y */
  28. /* A3: 15200 x, 10800 y -- GCG driver: 16000-0x, 10170-34y*/
  29. #define hpPageX   10800      /*10170 - 44 */
  30. #define hpPageY   7456        /*7680 */
  31.  
  32. #define LBEND     '~' /* LaBel end char, was 3 (^C),
  33.                       need non-control to work in HCard field...
  34.                       'ΓÇá' -- !! HI ascii is missed by this C !! */
  35.  
  36.  
  37.  
  38. /*!! dashline & dashstop postscript mess up my LN03R ps
  39.      w/ hacked apple ps dictionary, also LaserWRiter refused
  40.      to print it */
  41.  
  42. void dashline( int dashlength)
  43. {
  44. #define DashedLine   180
  45.  
  46.   typedef struct {
  47.     char  offset;
  48.     char  centered;
  49.     char  dashed[2]; /* ?? longer for patterned dash */
  50.     } tDashedLine, *pDashedLine, **hDashedLine;
  51.  
  52.   hDashedLine   hdash;
  53.  
  54.   (Handle) hdash  = NewHandle(sizeof(tDashedLine));
  55.   (**hdash).offset = 0;     /* ?? */
  56.   (**hdash).centered = 1;  /* ?? */
  57.   (**hdash).dashed[0] = 1; /* ?? */
  58.   (**hdash).dashed[1] = dashlength; /* ?? */
  59.   PicComment( DashedLine, GetHandleSize((Handle)hdash),
  60.       (Handle) hdash);
  61.   DisposHandle( (Handle)hdash);
  62. }
  63.  
  64. void dashstop(void)
  65. {
  66. #define DashedStop   181
  67.  
  68.    PicComment( DashedStop, 0, NULL);
  69. }
  70.  
  71. void  lineit(int linetype, int dashsize)
  72. { /* ?? need turtlegraphics to do dashed lines ? */
  73.   /* not working yet */
  74.  
  75.   switch (linetype) {
  76.     case 0:
  77.       /* dashstop(); */
  78.       break;
  79.     default:
  80.     case 1:
  81.     case 2:
  82.     case 3:
  83.     case 4:
  84.     case 5:
  85.     case 6:
  86.       dashsize = dashsize;
  87.       /* dashline(dashsize); */
  88.       break;
  89.     }
  90. }
  91.  
  92.  
  93.  
  94. void  laserline( int num, int denom)
  95. /* set postscript line width (rel to 1/72 dpi);
  96.   use num=1, denom=4 for 1/300 dpi line */
  97. {
  98. #define SetLineWidth    182
  99.   Point   **linesize;
  100.  
  101.   (Handle) linesize = NewHandle(sizeof(Point));
  102.   (**linesize).v = num;
  103.   (**linesize).h = denom;
  104.   PicComment( SetLineWidth, sizeof(Point), (Handle) linesize);
  105.   DisposHandle( (Handle) linesize);
  106. } /*laserline*/
  107.  
  108.  
  109.  
  110.  
  111. void  drawUpstr(int h, int v, int rotnum, char *s)
  112. {
  113. #define maxd  24
  114. #define maxdb 4   /* must be even */
  115. #define maxw  816 /* was 512 */
  116. #define maxwb 102 /* was 64 -- must be even */
  117.  
  118. typedef char  sbitarray[maxd][maxwb];
  119. typedef char  tbitarray[maxw][maxdb];
  120.  
  121. sbitarray *sbits, *sbit2;
  122. tbitarray *tbits;
  123. Ptr       tp;
  124. int       w,d,i,j;
  125. Rect      tor, sor;
  126. FontInfo  fi;
  127. BitMap    smap, smap2, tmap;
  128. GrafPtr   aport, offport;
  129.  
  130.  
  131.   GetPort( &aport); /* !! may be CGrafPort w/ pixmap */
  132.   GetFontInfo(&fi);
  133.   d  = min(maxd-1, fi.ascent + fi.descent + fi.leading);
  134.   w  = min(maxw-1, stringwidth(s));
  135.   /* h  = h - (d / 2); */  /*let h,v == topleft not center*/
  136.   /* v  = v - (w / 2); */
  137.   SetRect( &tor, h, v, h + d, v + w);
  138.   SetRect( &sor, h, v, h + w, v + d);
  139.  
  140.   (Ptr)sbits = NewPtr(sizeof(sbitarray));
  141.   for (i=0; i<sizeof(sbitarray); i++) ((char *)sbits)[i] = 0;
  142.   smap.baseAddr = (Ptr)sbits;
  143.   if ((long)smap.baseAddr % 2 == 1) ++smap.baseAddr; /* if odd(addr) */
  144.   smap.rowBytes  = maxwb;
  145.   SetRect( &smap.bounds, 0, 0, w, d);
  146.  
  147.   switch (rotnum) {
  148.    case 2:
  149.     (Ptr)sbit2 = NewPtr(sizeof(sbitarray));
  150.     for (i=0; i<sizeof(sbitarray); i++) ((char *)sbit2)[i] = 0;
  151.     smap2.baseAddr = (Ptr)sbit2;
  152.     if ((long)smap2.baseAddr % 2 == 1) ++smap2.baseAddr;
  153.     smap2.rowBytes  = maxwb;
  154.     SetRect( &smap2.bounds, 0, 0, w, d);
  155.     break;
  156.  
  157.    case 1:
  158.    case 3:
  159.     (Ptr)tbits = NewPtr(sizeof(tbitarray));
  160.     for (i=0; i<sizeof(tbitarray); i++) ((char *)tbits)[i] = 0;
  161.     tmap.baseAddr = (Ptr)tbits;
  162.     if ((long)tmap.baseAddr % 2 == 1) ++tmap.baseAddr;
  163.     tmap.rowBytes = maxdb;
  164.     SetRect( &tmap.bounds, 0, 0, d, w);
  165.     break;
  166.     }
  167.  
  168.   (Ptr) offport = NewPtr(sizeof(GrafPort)); /* forget CGrafPort */
  169.   OpenPort( offport);
  170.   SetPortBits( &smap);      /* set our offscreen map */
  171.   TextFont( aport->txFont);
  172.   TextSize( aport->txSize);
  173.   TextFace( aport->txFace);
  174.   MoveTo(0, fi.ascent);
  175.   drawstring(s);            /* draw the bugger */
  176.   ClosePort( offport);
  177.   DisposPtr( (Ptr)offport);
  178.   SetPort( aport);
  179.  
  180.   switch (rotnum) {
  181.  
  182.     case 2: /* 180┬░  ???*/
  183.       for (i=0; i < w; i++) {
  184.         for (j = 0; j < d; j++)
  185.           if (BitTst( &((*sbits)[j][0]), i))
  186.             BitSet( &((*sbit2)[d-j][0]), w-i);
  187.           }
  188.       OffsetRect( &sor, -w, 0/*-d*/); /* ? */
  189.       CopyBits( &smap2, &(aport->portBits), &smap2.bounds, &sor,
  190.             srcOr, NULL);
  191.       DisposPtr( (Ptr)sbit2);
  192.       break;
  193.  
  194.     case 0: /* here for completeness, or just drawstring */
  195.       CopyBits( &smap, &(aport->portBits), &smap.bounds, &sor,
  196.             srcOr, NULL);
  197.       break;
  198.  
  199.  
  200.     case 3:  /* = 270┬░, bottom left is start */
  201.       for (i = w - 1; i >= 0; i--) {
  202.         tp = &((*tbits)[w - (i + 1)][0]);
  203.         for ( j = 0; j < d; j++)
  204.           if (BitTst( &((*sbits)[j][0]), i)) BitSet(tp, j);
  205.         }
  206.       OffsetRect( &tor, -d, -w); /* ! */
  207.       CopyBits( &tmap, &(aport->portBits), &tmap.bounds, &tor,
  208.             srcOr, NULL);
  209.       DisposPtr( (Ptr)tbits);
  210.       break;
  211.  
  212.     case 1:   /* = 90┬░, top right is start */
  213.       for (i = 0; i<w; i++) {
  214.         tp = &((*tbits)[i][0]);
  215.         for (j = d - 1; j >= 0; j--)
  216.           if (BitTst( &((*sbits)[j][0]), i)) BitSet(tp, d - (j + 1));
  217.         }
  218.       CopyBits( &tmap, &(aport->portBits), &tmap.bounds, &tor,
  219.             srcOr, NULL);
  220.       DisposPtr( (Ptr)tbits);
  221.       break;
  222.     }
  223.  
  224.   DisposPtr( (Ptr)sbits);
  225. } /* drawUpstr */
  226.  
  227.  
  228.  
  229. void textPicDraw(int h, int v, int rot, char *s)
  230. {
  231. /* MacDraw standard drawString w/ rotation
  232.   h,v = _center_ of text rect
  233. */
  234. #define textBegin     150
  235. #define textEnd       151
  236. #define textCenter    154
  237.  
  238.   typedef struct {
  239.     char  tjus;     /* 0..4 == left,cent,right,full just */
  240.     char  tflip;    /* 0..2 == 0,horiz,vert flip */
  241.     short trot;     /* 0..360 rotate */
  242.     char  tline;    /* 1,2,3 line spacing */
  243.     char  tcmnt;    /* reserved */
  244.     } TxtPicRec, *pTxtPicRec, **hTxtPicRec;
  245.  
  246.   typedef struct  {
  247.     Fixed y, x;
  248.     } TxtCenter, *pTxtCenter, **hTxtCenter;
  249.  
  250.   int           w, d, rotnum;
  251.   Rect          zerorect;
  252.   FontInfo      fi;
  253.   hTxtPicRec    picdat;
  254.   hTxtCenter    xydat;
  255.   RgnHandle     saveclip;
  256.  
  257.  
  258.   rotnum = ((rot+44) % 360) / 90;
  259.   GetFontInfo( &fi);
  260.   d = (fi.ascent + fi.descent + fi.leading) / 2;
  261.   w = stringwidth(s) / 2;
  262.   MoveTo( h, v); /* ?? for HP text */
  263.   /* MoveTo(h - w, v - d); */ /* move from center */
  264.  
  265.   (Handle) picdat = NewHandle(sizeof(TxtPicRec));
  266.   (**picdat).tjus = 0;
  267.   (**picdat).tflip = 0;
  268.   (**picdat).trot = rot % 360;
  269.   (**picdat).tline = 1;
  270.   (**picdat).tcmnt = 0;
  271.   PicComment(textBegin, 6, (Handle) picdat);
  272.   DisposHandle( (Handle) picdat);
  273.  
  274.   (Handle)xydat = NewHandle(sizeof(TxtCenter));
  275.   (**xydat).x = Long2Fix(0);
  276.   (**xydat).y = Long2Fix(0);
  277.   PicComment( textCenter, 8, (Handle)xydat);
  278.   DisposHandle( (Handle)xydat);
  279.  
  280.   if (rotnum == 0) drawstring(s);
  281.   else {
  282.     saveclip = NewRgn();
  283.     GetClip( saveclip);
  284.     SetRect( &zerorect, 0,0,0,0);
  285.     ClipRect( &zerorect);
  286.     drawstring(s);
  287.     SetClip( saveclip);
  288.     DisposeRgn( saveclip);
  289.     drawUpstr( h, v, rotnum, s);
  290.     }
  291.   PicComment( textEnd, 0, NULL);
  292. } /*textPicDraw*/
  293.  
  294.  
  295.  
  296.  
  297. #define MAXTRIES      2
  298.  
  299. #define nextCmd(missing) { \
  300.     c2 = c; while (*c2 != 0 & *c2 != ';' & *c2 != 27) c2++; \
  301.     missing = (*c2 == 0); }
  302.  
  303. #define nextComma(missing) { \
  304.     c2 = c; while (*c2 != 0 & *c2 != ';' & *c2 != ',') c2++; \
  305.     if (*c2 != 0) do {++c2;} while (*c2 != 0 & *c2 != ';' & *c2 != ','); \
  306.     if (*c2 != 0) do {++c2;} while (*c2 != 0 & *c2 != ';' & *c2 != ','); \
  307.     missing = (*c2 == 0); }
  308.  
  309.  
  310. void  fetchmore(Handle hbuf, char **cv, XCmdPtr pXCmd)
  311. {
  312.   Boolean lookagain, newsize;
  313.   int     tries, n2, ce, i, ci;
  314.   char    *c, *c2, *buf2;
  315.   Handle  hbuf2;
  316.  
  317.  
  318. /* something about callback is messing up local xcmd/plot environ
  319.    -- the data saved to file & replotted (sometimes) works fine !
  320. */
  321.   c = *cv;
  322.   tries = 0;
  323.   do {
  324.     SendHCMessage(pXCmd, "\pset cursor to busy");
  325.     hbuf2 = EvalExpr(pXCmd, "\precvTo(empty,45,empty)");
  326.     n2 = GetHandleSize(hbuf2);
  327.     if (n2 < 2) tries++;
  328.     else {
  329.       ci = c - *hbuf;             /* save index into hbuf */
  330.       for (c2 = c; *c2 != 0; c2++) ; /* find end of hbuf */
  331.       ce = c2 - *hbuf;    /* index to end of current hbuf */
  332.       if (n2 + ce > GetHandleSize(hbuf)) {
  333.         HUnlock(hbuf);
  334.         SetHandleSize( hbuf, GetHandleSize(hbuf) + n2 + 10000);
  335.         c2 = *hbuf + ce;          /* find end after setsize */
  336.         /*if (*c2 != 0) ++c2; */    /* ?? did we get the 0 end */
  337.         newsize = true;
  338.         }
  339.       else
  340.         newsize = false;
  341.       buf2 = *hbuf2;
  342.       for (i = 0; buf2[i] != 0 & i < n2; i++) {
  343.         if ( buf2[i] == 3) *c2++ = LBEND;
  344.         else if (buf2[i] == LBEND | buf2[i] >= 27) *c2++ = buf2[i];
  345.         }
  346.       *c2 = 0;              /* tail of new, complete hbuf */
  347.       if (i < 1) tries++;
  348.       if (newsize) {
  349.         /* SetHandleSize(hbuf, 1 + c2 - *hbuf); */
  350.         HLock(hbuf);
  351.         c = *hbuf + ci;           /* restore index into hbuf */
  352.         }
  353.       }
  354.     DisposHandle(hbuf2);              /* done with this */
  355.     nextCmd(lookagain);
  356.     } while (lookagain & tries < MAXTRIES);
  357.  
  358.   *cv = c;
  359. }   /* fetchmore */
  360.  
  361.  
  362.  
  363. #define map2pic(x,y,h,v) { \
  364.   h = picrect->left + (x / xscale); \
  365.   v = picrect->top + ((ymax - y) / yscale); \
  366.   }
  367. #define maprel2pic(x,y,h,v) { \
  368.   h = (x / xscale); v = (( - y) / yscale); \
  369.   }
  370.  
  371. PicHandle   hp2pict( Boolean forpage, Rect *picrect, Handle hbuf,
  372.             WindowPtr myWind, Boolean commfetch, Boolean *alldone,
  373.             XCmdPtr pXCmd)
  374. {
  375.   char      *c, *c2, *ce, *si, s[256];
  376.   int       cmd, hpx, hpy, x, y, xd, yd, h, v, k, pageno;
  377.   Boolean   dorel, atend, done, lookagain, moveit, penup;
  378.   Rect      wr, hprect;
  379.   Point     pt;
  380.   float     fx, fy, linedash, xscale, yscale;
  381.   int       linetype, ymax, rot = 0;
  382.   RGBColor  bcolor;
  383.   PicHandle pic;
  384.  
  385.   HLock( hbuf);
  386.   c = (char *) (*hbuf);
  387.   while ((*c != 0) & (*c != ';')) c++;
  388.   if (*c == ';') c++;
  389.   hpx = hpPageX;
  390.   hpy = hpPageY;
  391.  
  392. redraw:
  393.  
  394.   pageno = 0;
  395.   *alldone = false;
  396.   pic = OpenPicture(picrect);
  397.   if (!forpage) {
  398.     InsetRect( picrect, 10, 8);
  399.     OffsetRect( picrect, 0, 5);
  400.     ShowPen();
  401.     if (hasColorQD()) {
  402.       bcolor.red  = 56000;
  403.       bcolor.green= 60000;
  404.       bcolor.blue = 65000;
  405.       if (lotsOfColor(myWind)) RGBBackColor( &bcolor);
  406.       EraseRect( &myWind->portRect);
  407.       }
  408.     }
  409.   SetRect( &wr, -10000, -10000, 30000, 30000);
  410.   ClipRect(&wr);
  411.  
  412.   TextFont(times);
  413.   if (forpage) TextSize(12);
  414.   else TextSize(9);
  415.   laserline(1, 2);
  416.   PenNormal();
  417.   penup = true;
  418.   dorel = false;
  419.   linetype  = 0;
  420.   linedash  = 1;
  421.  
  422.   SetRect( &hprect, 0, 0, hpx, hpy);
  423.   ymax = hpy;
  424.   xscale = hpx / (picrect->right - picrect->left);
  425.   yscale = hpy / (picrect->bottom - picrect->top);
  426.  
  427.   done = (*c == 0);
  428.  
  429.   while (!done) {
  430.     while ((!Isalpha(*c)) && (*c != 0)) c++; /* skip to start of cmd */
  431.     /* ^^ this messes up '\27.' end of transmission */
  432.  
  433.     cmd = (Toupper(*c++))*256 + (Toupper(*c++));
  434.     atend = false;
  435.  
  436.     switch (cmd) {
  437.  
  438.       case '\27.': /* 6958 == '\27.' */ /* not seen ? */
  439.         if (*c == ')') {
  440.           atend = true;
  441.           done = true;
  442.           *alldone = true;
  443.           *c = 0;
  444.   SysBeep(2);
  445.           }
  446.         break;
  447.  
  448.       case 'AF':
  449.         /* the end-of-plot signal is "AF;\27.)x" */
  450.         /* multi-page plots will want me to throw up a new
  451.            plot window -> from Draw */
  452.         if ( (++pageno > 1) | (c[1] == '\27' & c[3] == ')') ) {
  453.           atend = true;
  454.           done = true;
  455.           *c = 0;
  456.   SysBeep(1);
  457.           }
  458.         break; /* autopage */
  459.  
  460.       case 'IN':
  461.         /* the start-of-plot signal is */
  462.         /* "\27.(\27.N;19:\27.I81;;17:IN;...AF;" */
  463.         break; /* initialize */
  464.  
  465.       case 'AA': break; /* arc */
  466.       case 'IP': break; /* frame */
  467.  
  468.       case 'LB':
  469.         if (commfetch) {
  470.           nextCmd(lookagain);
  471.           if (lookagain) fetchmore(hbuf, &c, pXCmd);
  472.           }
  473.         for (si=0; *c != LBEND & si < 256; si++, c++)
  474.             s[si] = *c;
  475.         s[si] = 0;
  476.         /* drawstring(s); */
  477.         /*  -- use last valid h,v, rot */
  478.         /* Note: this h,v is left,top? of string, not center */
  479.         textPicDraw( h, v, rot, s);
  480.         ++c; atend = true;
  481.         break; /* LBlabel^C; */
  482.  
  483.       case 'LO':
  484.         x = Strtod( c, &ce); if (ce == c) break;
  485.         c = ce;
  486.         break; /* ? Label Offset move ?? */
  487.  
  488.       case 'LT':
  489.         k = linetype;
  490.         linetype = 0;
  491.         if (*c != ';') {
  492.           linetype = Strtod( c, &ce);
  493.           if (ce != c) {
  494.             c = ce; if (*c == ',') c++;
  495.             linedash = Strtod( c, &ce);
  496.             c = ce;
  497.             }
  498.         }
  499.         if (linetype != k | linetype > 0) {
  500.           maprel2pic(linedash,linedash, xd, yd);
  501.           xd = max( abs(xd), abs(yd));
  502.           lineit( linetype, xd);
  503.           }
  504.         break; /* LT#,#; line type (style, %diag) */
  505.  
  506.       case 'PU':
  507.         penup = true;
  508.         if (*c == ';') break;
  509.         x = Strtod( c, &ce); if (ce == c) break;
  510.         c = ce; if (*c == ',') c++;
  511.         y = Strtod( c, &ce); if (ce == c) break;
  512.         c = ce;
  513.         map2pic( x, y, h, v);
  514.         MoveTo(h,v);
  515.         break; /* PU[#,#];penup */
  516.  
  517.       case 'PR':  /* PR#,#[...]; rel move */
  518.         dorel = true;
  519.         goto penat;
  520.  
  521.       case 'PD':  /* PD[#,#,...]; pendn */
  522.         penup = false;
  523.         goto penat;   /* slide into PA loop */
  524.  
  525.       case 'PA':
  526.         dorel = false;
  527.         moveit = (*c != ',');
  528. penat:
  529.         do {
  530.           if (*c == ',') c++;
  531.           if (commfetch) {
  532.             nextComma(lookagain);
  533.             if (lookagain) fetchmore(hbuf, &c, pXCmd);
  534.             }
  535.     /* during commfetch, this loop gets bad, but hbuf data is good !? */
  536.           x = Strtod( c, &ce); if (ce == c) break;
  537.           c = ce; if (*c == ',') c++;
  538.           y = Strtod( c, &ce); if (ce == c) break;
  539.           c = ce;
  540.           if (dorel) {
  541.             maprel2pic( x, y, h, v);
  542.             if (penup | moveit) Move(h,v);
  543.             else Line(h,v);
  544.             GetPen(&pt);
  545.             h = pt.h; v = pt.v; /* save for LB */
  546.             }
  547.           else {
  548.             map2pic( x, y, h, v);
  549.             if (penup | moveit) MoveTo(h,v);
  550.             else LineTo(h,v);
  551.             }
  552.           moveit = false;
  553.           } while (true);
  554.         break; /* PA#,#[,#,#...]; mvabs */
  555.  
  556.       case 'RO':
  557.         x = Strtod( c, &ce);
  558.         if ((x > 60 & x < 120) && !forpage) {
  559.           /* can't do for printed page?? -- need to mangle  
  560.              page orientation in pageSetup... */
  561.           hpx = hpPageY;
  562.           hpy = hpPageX;
  563.  
  564.           xd = picrect->right;
  565.           picrect->right = picrect->bottom;
  566.           picrect->bottom = xd;
  567.  
  568.           if (!forpage) HidePen();
  569.           ClosePicture();
  570.           KillPicture( pic);
  571.  
  572.           xd = myWind->portRect.right - myWind->portRect.left;
  573.           yd = myWind->portRect.bottom - myWind->portRect.top;
  574.           SizeWindow( myWind, yd, xd, true);
  575.           /* need to redraw it NOW ? */
  576.           BringToFront( myWind);
  577.           //BeginUpdate( myWind);
  578.           //EraseRect( &myWind->portRect);
  579.           //EndUpdate( myWind);
  580.  
  581.           goto redraw;
  582.           }
  583.         break; /* RO#; rotate plot */
  584.  
  585.       case 'SP':
  586.         x = Strtod( c, &ce);
  587.         switch (x) {
  588.           /* pen colors should be user option */
  589.           /* this form works w/ PICT1(b/w) as well as PICT2 */
  590.           default:
  591.           case 1: ForeColor(blackColor); break;
  592.           case 2: ForeColor(greenColor); break;
  593.           case 3: ForeColor(blueColor); break;
  594.           case 4: ForeColor(redColor); break;
  595.           case 5: ForeColor(cyanColor); break;
  596.           case 6: ForeColor(magentaColor); break;
  597.           case 7: ForeColor(yellowColor); break;
  598.           case 8: ForeColor(blackColor); break;
  599.           }
  600.         /* set color to # */
  601.         break; /* SP[#]; select pen */
  602.  
  603.       case 'SI':
  604.         if (*c == ';') break;
  605.         fx = Strtod( c, &ce); if (ce == c) break;
  606.         c = ce; if (*c == ',') c++;
  607.         fy = Strtod( c, &ce); if (ce == c) break;
  608.         c =  ce;
  609.         /* map fx,fy into TextSize ?? */
  610.         break; /* SI#,#; set text abs width,abs height ? */
  611.  
  612.       case 'DI':
  613.         rot = 0;
  614.         if (*c == ';') break;
  615.         fy = Strtod( c, &ce); if (ce == c) break;
  616.         c = ce; if (*c == ',') c++;
  617.         fx = Strtod( c, &ce); if (ce == c) break;
  618.         c =  ce;
  619.           /* rot == atan2(fx, fy); */
  620.           /* left/right rot are reversed !? */
  621.         if ((fx == 0.0) & (fy == 0.0)) rot = 360;
  622.         else if (fx == 0.0) rot = 0; /* ? or 180 */
  623.         else if (fy == 0.0) rot = 90;
  624.         else rot = atan( abs(fx/fy));
  625.         if (fy < 0.0) rot = 180 - rot;
  626.         /*if (fx < 0.0) rot = 360 - abs(rot); */
  627.         /* GCG or HPGL is bassackwards on rotation handling */
  628.         if (fx > 0.0) rot = 360 - abs(rot);
  629.         else rot = abs(rot);
  630.         break; /* DI#,#; text direction */
  631.               /* (run = cos(direction), rise = sin(direction) */
  632.  
  633.       case 'SL':
  634.         break; /* SL[#]; set text slant (tangent) ? */
  635.  
  636.       case 'SC': break; /* scale */
  637.       case 'VS': break; /* VS#; pen speed */
  638.  
  639.       case 'CI':   /* filled oval */
  640.         x = Strtod( c, &ce); if (ce == c) break;
  641.         c = ce; if (*c == ',') c++;
  642.         y = Strtod( c, &ce); if (ce == c) break;
  643.         c = ce;
  644.         maprel2pic( x+1, y+1, h, v);
  645.         h = min(h,abs(v));  /* h is bad(huge) for card-sized plot */
  646.         GetPen(&pt);
  647.         SetRect(&wr, pt.h, pt.v, pt.h, pt.v);
  648.         InsetRect(&wr, -h, -h);
  649.         /* FillOval(&wr, black); */
  650.         PaintOval(&wr);
  651.         break;
  652.  
  653.       default : break;
  654.       }
  655.  
  656.     if (!atend)
  657.       while ((*c != 0) && (*c != ';') && (!Isalpha(*c)))
  658.         c++; /* skip to end cmd */
  659.     if (*c == ';') c++;
  660.  
  661.     if (commfetch & !done) {
  662.       nextCmd(lookagain);
  663.       if (lookagain) fetchmore(hbuf, &c, pXCmd);
  664.       }
  665.     if (*c == 0) done = true;
  666.     }
  667.  
  668.   if (!forpage) HidePen();
  669.   ClosePicture();
  670.   HUnlock( hbuf);
  671.  
  672.   return pic;
  673.  
  674. } /* hp2pict */
  675.